package com.taoyibao.hongcanting.ui.mine.delegate;

import android.content.Intent;
import android.view.View;
import android.widget.TextView;

import com.taoyibao.hongcanting.R;
import com.taoyibao.hongcanting.base.delegate.ColorToolbarDelegate;
import com.taoyibao.hongcanting.model.BalanceModel;
import com.taoyibao.hongcanting.ui.mine.activity.RechargeActivity;
import com.taoyibao.hongcanting.ui.mine.activity.WalletDetailsActivity;
import com.taoyibao.hongcanting.utils.CodeUtils;

import java.util.List;

/**
 * @author TangAnna
 * @description:
 * @date :${DATA} 9:48
 */
public class WalletDelegate extends ColorToolbarDelegate implements View.OnClickListener, ColorToolbarDelegate.OnRightClickListener {
    @Override
    public int getRootLayoutId() {
        return R.layout.activity_wallet;
    }

    @Override
    public void initWidget() {
        super.initWidget();
        setTitle(CodeUtils.getIdString(R.string.string_mineWallet));
        setBackHeadGray();
        setRightText(CodeUtils.getIdString(R.string.string_detail));
        setRightImg(R.drawable.mingxi);
        get(R.id.tv_wallet_recharge).setOnClickListener(this);
        setOnRightClickListener(this);

    }

    public void setBalanceUI(List<BalanceModel> balanceModel) {
        if (balanceModel == null || balanceModel.size() < 1) {
            return;
        }
        BalanceModel dataModel = balanceModel.get(0);
        ((TextView) get(R.id.tv_wallet_totalAmount)).setText(CodeUtils.formatAmount2String((dataModel.balance + dataModel.interests)));
        ((TextView) get(R.id.tv_wallet_xiaoFeiAmount)).setText(CodeUtils.formatAmount2String(dataModel.interests));
        ((TextView) get(R.id.tv_wallet_rechargeAmount)).setText(CodeUtils.formatAmount2String(dataModel.balance));
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tv_wallet_recharge://充值
                getActivity().startActivity(new Intent(getActivity(), RechargeActivity.class));
                break;
        }
    }

    @Override
    public void onRightClick(View view) {
        getActivity().startActivity(new Intent(getActivity(), WalletDetailsActivity.class));
    }
}
